//
//  HJCommonDto.m
//  KaiChat
//
//  Created by lx on 2023/10/21.
//

#import "HJMessageDto.h"
#import "HJChatMessageModel.h"

@implementation HJMessageDto

MJLogAllIvars


+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{
        @"chatType": @"op",
        @"serverMsgId": @"seq_id",
        @"messagType": @"typ",
        @"sessionId": @"session_id",
        @"content": @"msg",
        @"timestamp": @"send_time_for_client",
        @"fileSize": @"file_size",
        @"originUrl": @"origin_picture"
    };
}

+ (NSArray *)mj_ignoredPropertyNames {
    return @[@"urlPath"];
}

//发送消息
- (instancetype)initWithMessageModel:(HJChatMessageModel *)model {
    if (self = [super init]) {
        
        self.chatType = @(model.chatType);
        self.messagType = @(model.messageType);
        self.timestamp = [NSNumber numberWithInteger:model.timestamp.integerValue];
        self.content = model.content;
        
        if (model.chatType == HJChatTypeSingle) {
            
            self.urlPath = API_sendSingleMessage;
            self.sessionId = toString(model.sessionId);
            self.uid = toString(model.receiverId);
            
        } else if (model.chatType == HJChatTypeGroup){
            
            self.urlPath = API_sendGroupMessage;
            self.sessionId = toString(model.groupId);
            
        } else {
            self.urlPath = nil;
        }
    }
    return self;
}

+ (instancetype)messageDtoWithMessageModel:(HJChatMessageModel *)model {
    return [[self alloc] initWithMessageModel:model];
}

//@property (nonatomic, strong) NSNumber *chatType;
//@property (nonatomic, strong) NSNumber *serverMsgId;
//@property (nonatomic, strong) NSNumber *messagType; //1-文本 2-图片3-语音 4-视频
//@property (nonatomic, strong) NSString *sessionId;
//@property (nonatomic, strong) NSString *uid;
//@property (nonatomic, strong) NSString *content;
//@property (nonatomic, strong) NSNumber *timestamp;


//@property (nonatomic, strong) NSNumber *op;
//@property (nonatomic, strong) NSNumber *seq_id;
//@property (nonatomic, strong) NSNumber *typ; //1-文本 2-图片3-语音 4-视频
//@property (nonatomic, strong) NSString *session_id;
//@property (nonatomic, strong) NSString *uid;
//@property (nonatomic, strong) NSString *msg;
//@property (nonatomic, strong) NSNumber *send_time_for_client;


@end
